<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>05.form_fields | KnockOut</title>
  <script src="../assets/knockout-3.5.1.js"></script>
</head>
<body>

  <p>
    目的地:
    <select data-bind="options: availableCountries, selectedOptions: chosenCountries" 
            size="5" 
            multiple="true"></select>
  </p>

  <script type="text/javascript">
    var vm = {
      availableCountries: ko.observableArray(['中国', '德国', '美国']),
      chosenCountries: ko.observableArray(['中国']) // 默认选中中国
    };

    // ... then later ...
    vm.chosenCountries.push('德国'); // 然后选中德国

    ko.applyBindings(vm);
  </script>
    
</body>
</html>